using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Plain.Demo.Blog.Business;
using NHibernate.Tool;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;

namespace Plain.Demo.Blog.Web.UI
{
	public class MvcApplication : System.Web.HttpApplication
	{
		public static void RegisterRoutes (RouteCollection routes)
		{
			routes.IgnoreRoute ("{resource}.axd/{*pathInfo}");
			
			routes.MapRoute ("Default", "{controller}/{action}/{id}", new {
				controller = "Blog",
				action = "Index",
				id = ""
			}, new  { controller="(Blog)" });
			
			routes.MapRoute("ArchiveMonth","{controller}/Archive/{action}/{year}/{month}", new { controller = "Blog", action = "Month"});
			routes.MapRoute("ArchiveYear","{controller}/Archive/{action}/{year}", new { controller = "Blog", action = "Year"});
			routes.MapRoute("Admins","Admin/{controller}/{action}/{id}", new { controller = "Post", action = "Index", id = ""});
		}

		protected void Application_Start ()
		{	
			RegisterRoutes (RouteTable.Routes);
			NHibernate.Cfg.Configuration _cfg = new NHibernate.Cfg.Configuration(); 
		    _cfg.Configure();
		    SchemaUpdate update = new SchemaUpdate(_cfg); 
		    update.Execute(true,true);			
		}
	}
}

